package com.hmdp.utils;

import cn.hutool.json.JSONUtil;

import java.util.Collection;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class StreamUtil {

    public static <T> Collection<T> mapToBean(Stream<String> stream, final Class<T> clazz) {
        return stream.map(jsonStr -> JSONUtil.toBean(jsonStr, clazz)).collect(Collectors.toList());
    }

    public static <T> Collection<String> mapToJsonStr(Stream<T> stream) {
        return stream.map(JSONUtil::toJsonStr).collect(Collectors.toList());
    }
}
